﻿@model dynamic

@{
    ResFile = "cms_Metas";
    IList<CmsEntityMetaFieldLink> data = (IList<CmsEntityMetaFieldLink>) Model.Data;
    string editUrl = Model.EditUrl;
}

    @(Html.CmsGrid(data, new { @class = "t-grid t-grid_meta" }).Wrapper("MetaFiedls")
          .Columns(cols =>
                       {
                           cols.Bound().Title(_("Internal name")).HtmlAttributes(new { @class = "t-header" });
                           cols.Bound().Title(_("Display name")).HtmlAttributes(new { @class = "t-header" });
                           cols.Bound().Title(_("System type")).HtmlAttributes(new { @class = "t-header t-header_m" });
                           cols.Bound().Title(_("Order")).HtmlAttributes(new { @class = "t-header" });
                           cols.Bound().Title(_("Edit")).HtmlAttributes(new { @class = "t-header" });
                           cols.Bound().Title(_("Delete")).HtmlAttributes(new { @class = "t-header t-last-header" });
                       })
          .Rows(rows =>
                    {
                        rows.Bound().RowItemTemplate(@<text><a href="@(editUrl + "/" + item.Id)">@item.EntityMetaField.MetaFieldName</a></text>);
                        rows.Bound().RowItemTemplate(@<text>@item.DisplayLabel</text>);
                        rows.Bound().RowItemTemplate(@<text><div class="meta_data">@item.EntityMetaField.MetaFieldType</div></text>);
                        rows.Bound().RowItemTemplate
                            (@<text>
                            @if(!item.IsFirst)
                            {
                                <a href="@Url.Action("moveup", "cmsmetafield", new {id = item.Id})" class="b-icon b-icon_up js-ajax-link" data-container="#MetaFiedls"></a>
                            }
		    	            @if (!item.IsLast)
                            {
                                <a href="@Url.Action("movedown", "cmsmetafield", new { id = item.Id})" class="b-icon b-icon_down js-ajax-link" data-container="#MetaFiedls"></a>
                            }
                            </text>);
                        rows.Bound().RowItemTemplate(@<text><a href="@(editUrl + "/" + item.Id)">@_("Edit")</a></text>);
                        rows.Bound().RowItemTemplate(
                            @<text>
                                 <a class="b-icon b-icon_delete_custom js-ajax-link" data-container="#MetaFiedls" data-confirm-message="@_("Are you sure you want to delete this meta field and all its values?")" href="@Url.Action("DeleteMetaLink", "cmsmetafield", new { id = item.Id })">@_("Delete")</a>
                             </text>).HtmlAttributes(new { @class = "text-center" });
                    })
          //.NoItemsTemplate(@<text>There are no any page meta fields yet</text>)
          .Render()
      )